//
//  ZZCarTVCell.m
//  新项目
//
//  Created by Gamin on 2016/12/20.
//  Copyright © 2016年 刘耀宗. All rights reserved.
//

#import "ZZCarTVCell.h"

@implementation ZZCarTVCell
@synthesize dataModel = _dataModel;

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)dealloc {
    [self releaseAction];
}

- (void)releaseAction {
    _limitWidth.constant = 0;
    _lineView.hidden = YES;
    _markImgView.hidden = YES;
    _priceLab.hidden = YES;
    _markImgView.image = nil;
    _titleLab.text = @"";
    _priceLab.text = @"";
    _namePhoneLab.text = @"";
    _timeLab.text = @"";
    _carModelLab.text = @"";
    _dataModel = nil;
}

- (void)assignmentDataWithModel:(ZZCarTVModel *)theModel andSelectMark:(NSInteger)theSelectMark andRow:(NSInteger)theRow {
    [self releaseAction];
    if(theModel){
        _dataModel = theModel;
        _lineView.hidden = NO;
        _markImgView.hidden = NO;
        if(theSelectMark==3){ // 结算
            _priceLab.hidden = NO;
            _limitWidth.constant = 75;
            _timeLab.text = [DMToolsObject cStringFromTimestampMDHM:_dataModel.mClearTime];
        }else{
            _timeLab.text = [DMToolsObject cStringFromTimestampMDHM:_dataModel.mRepairTime];
        }
        _titleLab.text = _dataModel.mTitle;
        _priceLab.text = [NSString stringWithFormat:@"￥%.2f",[_dataModel.mPrice floatValue]];
        _namePhoneLab.text = [NSString stringWithFormat:@"%@  |  %@",_dataModel.mUserName,_dataModel.mPhone];
        if([_dataModel.mCarNumber isEqualToString:@""]){
            _carModelLab.text  = _dataModel.mCarModel;
        }else{
            _carModelLab.text  = [NSString stringWithFormat:@"%@（%@）",_dataModel.mCarModel,_dataModel.mCarNumber];
        }
        
        NSInteger typeMark = [_dataModel.mType integerValue];
        if(typeMark == 1){ // 美容
            [_markImgView setImage:[UIImage imageNamed:@"ic_list_mr.png"]];
        }else if(typeMark == 2){ // 保养
            [_markImgView setImage:[UIImage imageNamed:@"ic_list_by.png"]];
        }else if(typeMark == 3){ // 维修
            [_markImgView setImage:[UIImage imageNamed:@"ic_list_wx.png"]];
        }else{ // 缺省
            [_markImgView setImage:[UIImage imageNamed:@"ic_list_mr.png"]];
        }
    }
}


@end
